var con = new Vue({
    el:"#con",
    data:{
        student:{sname:"",age:"",gender:"",phoneNum:"",size:"",addr:"",height:""},
        studentList:[]
    },
    methods:{
        findAll:function (pn) {
            if(pn == null){
                pn = 1
            }
            var this_ = this;
            axios.get("student/findAll.do",{params:{pageNum:pn}}).then(function (value) {
                this_.studentList = value.data
            }).catch(function (err) {
                console.log("请求列表失败")
            })
        },
        deleteById:function (id) {
            var this_ = this;
            axios.get("student/delete.do",{params:{
                id:id
                }}).then(function (resp) {
                if (resp.data != 1){
                    alert("删除失败")
                }
                this_.findAll()
            }).catch(function (error) {

            })
        },
        findById:function (id) {
            var this_ = this;
            axios.get("student/findById.do",{params:{
                id:id
                }}).then(function (resp) {
                this_.student = resp.data
            }).catch(function (err) {
                alert("没找到该学生")
            })
        },
        save:function () {
            var this_ = this;
            var params = $("form").serialize()
            alert(params)
            axios.post("student/save.do",params).then(function (resp) {
                this_.findAll()
            }).catch(function (reason) {
                alert("存储失败")
            })
        }
    },
    created(){
        this.findAll()
    }
})

